﻿using Colorful.Models;
using NodaTime;
using System;
using System.Collections.Generic;
using System.Linq;


namespace Colorful.Apps.MemberSystem.Models
{
    /// <summary>
    /// 会员
    /// </summary>
    public class Member : BaseId
    {
        /// <summary>
        /// 上级
        /// </summary>
        public string ParentId { get; set; }
        /// <summary>
        /// 会员卡号
        /// </summary>
        public string CardId { get; set; }
        /// <summary>
        /// 会员卡号类型
        /// </summary>
        public int CardType { get; set; }
        /// <summary>
        /// 余额
        /// </summary>
        public decimal Money { get; set; }
        /// <summary>
        /// 积分
        /// </summary>
        public long Point { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 会员头像
        /// </summary>
        public string Photo { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public string Sex { get; set; }
        /// <summary>
        /// 生日
        /// </summary>
        public DateTime Birthday { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        public string Tel { get; set; }
        public string Mobile { get; set; }
        public string Email { get; set; }
        public string QQ { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 最后充值时间
        /// </summary>
        public DateTime LastRecharge { get; set; }
        /// <summary>
        /// 到期时间
        /// </summary>
        public DateTime ExpirationDate { get; set; }
        public string Keyword { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public long ByOrder { get; set; }

        #region Ignore
        //public int RechargeYears
        //{
        //    get
        //    {
        //        if (this.ExpirationDate > this.LastRecharge)
        //        {
        //            var year = (DateTime.MinValue + (this.ExpirationDate - this.LastRecharge)).Year - 1;

        //            LocalDate start = new LocalDate(this.ExpirationDate.Year, this.ExpirationDate.Month, this.ExpirationDate.Day);
        //            LocalDate end = new LocalDate(LastRecharge.Year, LastRecharge.Month, LastRecharge.Day);
        //            Period period = Period.Between(start, end, PeriodUnits.Years | PeriodUnits.Days);
        //            year = period.Years;

        //            return year;
        //        }
        //        return 0;
        //    }
        //}
        #endregion
    }
}